package mgslangpack;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import javax.swing.*;
public class AddBooking
{
    public AddBooking() throws Exception
    {
        final TextField tf1,tf2,tf3;
        Label l1,l2,l3,l4;
        Button b1,b2,b3;        
        final JFrame jf= new JFrame("Add Booking");
        jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        jf.setSize(800,600);
        jf.setLayout(null);
        jf.setVisible(false);        
        Container ctn=jf.getContentPane();
        ctn.setBackground(Color.LIGHT_GRAY);
        JLabel Pic;
        Pic=new JLabel(new ImageIcon("1299997823-43.jpg"));
        Pic.setBounds(200,140,400,412);
        ctn.add(Pic);
        Font f1 = new Font("Lucida Handwriting",Font.BOLD,24);
        l1 = new Label("Add Booking Information");
        l1.setBounds(150,10,800,40);
        l1.setFont(f1);
        jf.add(l1);
        l2= new Label("Booking Reff:");
        l2.setBounds(200,50,100,40);
        jf.add(l2);
        tf1 = new TextField();
        tf1.setBounds(380,50,200,25);
        jf.add(tf1);
        l3=new Label("Booked Date:");
        l3.setBounds(200,80,150,40);
        jf.add(l3);
        tf2 = new TextField();
        tf2.setBounds(380,80,100,25);
        jf.add(tf2);
        l4= new Label("Number Of Expected Guests:");
        l4.setBounds(200,110,180,30);
        jf.add(l4);
        tf3 = new TextField();
        tf3.setBounds(380,110,30,25);
        jf.add(tf3);
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        final Connection con =
        DriverManager.getConnection("jdbc:odbc:TheOZ_DB","","");
        b1 = new Button("ADD");
        b1.setBounds(30,10,80,30);
        b1.addActionListener( new ActionListener()
        {
            public void actionPerformed(ActionEvent e)
            {
                try
                {
                    String s1,s2,s3;
                    s1=tf1.getText();
                    s2=tf2.getText();
                    s3=tf3.getText();
                    PreparedStatement ps = con.prepareStatement("insert into Bookings values(?,?,?)");
                    ps.setString(1,s1);
                    ps.setString(2,s2);
                    ps.setString(3,s3);
                    int i = ps.executeUpdate();
                    JOptionPane.showMessageDialog(null,"Booked date Added");
                    tf1.setText("");
                    tf2.setText("");
                    tf3.setText("");
                }
                catch(Exception e1)
                {
                    JOptionPane.showMessageDialog(null,"Error On Input Data!");
                }
            }
        }
        );        
        jf.add(b1);
        b2 = new Button("Back");
        b2.setBounds(30,110,80,30);
        b2.addActionListener(new ActionListener()
        {
            public void actionPerformed(ActionEvent e2)
            {
                try
                {
                    jf.hide();
                    MenuStaff m = new MenuStaff();
                }
                catch(Exception e3){}
            }
        }
        );
        jf.add(b2);
        b3 = new Button("Exit");
        b3.setBounds(680,50,80,30);
        b3.addActionListener(new ActionListener()
        {
            public void actionPerformed(ActionEvent e2)
            {
                try
                {
                    System.exit(0);
                }
                catch(Exception e3){}
            }
        }
        );
        jf.add(b3);
        jf.show();
    }
}
/******************************************************************************/